package com.lz.controller;

import com.lz.feignClient.FeignA;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("test/lz")
public class TestController {

    @Autowired
    FeignA feignA;
//    @Autowired
//    RestTemplate restTemplate;
//    @Resource
//    RibbonLoadBalancerClient client;

//    @RequestMapping("/h")
//    public void test(){
//        String url = "http://eureka-client-a/test/lz/hello";
//        String forObject = restTemplate.getForObject(url, String.class);
//        System.out.println(forObject);
//    }

//    @RequestMapping("/J")
//    public void test1(){
//        for (int i = 0; i < 100; i++) {
//            ServiceInstance instance = client.choose("eureka-client-a");
//            System.out.println(instance.getHost() + ":" +instance.getPort());
//        }
//    }


    @RequestMapping("/J")
    public void test1() {
        String test = feignA.test();
        System.out.println(test);
    }
}
